﻿using System.Collections;
using UnityEngine;
using System;

#if UNITY_EDITOR
using UnityEditor;
#endif

[Serializable]
public class GT_ViewBase {

    public string viewTitle;
    public Rect viewRect;

    protected GUISkin viewSkin;
    protected GT_NodeGraph curGraph;

    public GT_ViewBase(string title)
    {
        viewTitle = title;
        GetEditorSkin();
    }

    #region Main Methods
    public virtual void UpdateView(Rect editorRect, Rect percentageRect, Event e, GT_NodeGraph curGraph)
    {
        if(viewSkin == null)
        {
            GetEditorSkin();
            return;
        }
        this.curGraph = curGraph;
        if (curGraph != null)
        {
            viewTitle = curGraph.graphName;
        }
        else
        {
            viewTitle = "No Graph";
        }
        viewRect = new Rect(editorRect.x * percentageRect.x,
                            editorRect.y * percentageRect.y,
                            editorRect.width * percentageRect.width,
                            editorRect.height * percentageRect.height);
    }
    public virtual void ProcessEvent(Event e) { } 
    #endregion

    protected void GetEditorSkin()
    {
        viewSkin = (GUISkin)Resources.Load("GUISkins/EditorSkins/NodeEditorSkin");
    }
}
